@using OrchardCore.Commerce.Abstractions.Constants
@model OrderPartViewModel

<section id="shopping-cart">
    @if (Model.LineItems?.Any() == true)
    {
        <div class="container">
            <table class="table">
                <thead>
                    <tr>
                        <th scope="col">@T["Quantity"]</th>
                        <th scope="col">@T["Product"]</th>
                        <th scope="col">@T["Attributes"]</th>
                        <th scope="col">@T["Price"]</th>
                    </tr>
                </thead>
                <tbody>
                    @foreach (var item in Model.LineItems)
                    {
                        <tr>
                            <td>@item.Quantity@T[" × "]</td>
                            <td><a href="@Url.RouteUrl(item.ProductRouteValues)">@item.ProductName</a></td>
                            <td>
                                @if (item.Attributes != null)
                                {
                                    <ul class="cart-product-attributes list-inline">
                                        @foreach (var attribute in item.Attributes.Where(value => value.UntypedValue != null))
                                        {
                                            <shape tag="li"
                                                   Type="@(attribute.GetType().Name)"
                                                   prop-attribute="@(attribute)"
                                                   prop-product="@item.ProductPart.ContentItem"
                                                   prop-label="@(attribute.Label)" />
                                        }
                                    </ul>
                                }
                            </td>
                            <td>@item.UnitPrice</td>
                        </tr>
                    }
                </tbody>
            </table>
            <div class="row mt-3 mb-3 pb-2">
                <div class="col-xs-12 col-sm-10 font-weight-bold">@T["Total"]</div>
                <div class="col-xs-12 col-sm-1">
                    <div class="order-total">@Model.Total</div>
                </div>
            </div>
        </div>
        @if (string.Equals(Model.OrderPart.Status.Text, OrderStatuses.Pending, StringComparison.OrdinalIgnoreCase))
        {
            <div class="my-2 d-flex justify-content-center">
                <div class="pay-button-container">
                    <a href="@Url.Content($"~/checkout/paymentrequest/{Model.OrderPart.ContentItem.ContentItemId}")"
                       class="pay-button btn btn-success justify-content-center" >
                        <span class="pay-text">
                            @T["Complete Payment"]
                        </span>
                    </a>
                </div>
            </div>
        }
    }
    else
    {
        <p>@T["This order is empty."]</p>
    }
</section>
<div class="form-group order-charges">
    <div class="panel-heading">
        <label>@T["Charges"]</label>
    </div>
    @if (Model.Charges?.Any() == true)
    {
        @foreach (var charge in Model.Charges)
        {
            <table class="table order-charge">
                <tr>
                    <th scope="row">@T["Kind:"]</th>
                    <td class="order-charge-kind">@charge.Kind</td>
                </tr>
                <tr>
                    <th scope="row">@T["Amount:"]</th>
                    <td class="order-charge-amount">@charge.Amount</td>
                </tr>
                <tr>
                    <th scope="row">@T["Transaction Id:"]</th>
                    <td class="order-charge-transaction-id">@charge.TransactionId</td>
                </tr>
                <tr>
                    <th scope="row">@T["Created:"]</th>
                    <td class="order-charge-created">@charge.CreatedUtc</td>
                </tr>
                <tr>
                    <th scope="row">@T["Charge Text:"]</th>
                    <td class="order-charge-text">@charge.ChargeText</td>
                </tr>
            </table>
        }
    }
    else
    {
        <p>@T["There are no charges stored in this order."]</p>
    }
</div>
